package com.hckjsec.cloud.service.impl;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.hckjsec.cloud.domain.AppletsConfig;
import com.hckjsec.cloud.mapper.AppletsConfigMapper;
import com.hckjsec.common.init.YwInitData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hckjsec.cloud.service.IAppletsConfigService;

/**
 * applets配置Service业务层处理
 * 
 * @author cyt
 * @date 2021-07-27
 */
@Service
public class AppletsConfigServiceImpl implements IAppletsConfigService 
{
    @Autowired
    private AppletsConfigMapper appletsConfigMapper;

    @Autowired
    private YwInitData ywInitData;

    /**
     * 查询applets配置
     * 
     * @param id applets配置ID
     * @return applets配置
     */
    @Override
    public AppletsConfig selectAppletsConfigById(Long id)
    {
        return appletsConfigMapper.selectAppletsConfigById(id);
    }

    /**
     * 查询applets配置列表
     * 
     * @param appletsConfig applets配置
     * @return applets配置
     */
    @Override
    public List<AppletsConfig> selectAppletsConfigList(AppletsConfig appletsConfig)
    {
        return appletsConfigMapper.selectAppletsConfigList(appletsConfig);
    }

    /**
     * 新增applets配置
     * 
     * @param appletsConfig applets配置
     * @return 结果
     */
    @Override
    public int insertAppletsConfig(AppletsConfig appletsConfig)
    {
        return appletsConfigMapper.insertAppletsConfig(appletsConfig);
    }

    /**
     * 修改applets配置
     * 
     * @param appletsConfig applets配置
     * @return 结果
     */
    @Override
    public int updateAppletsConfig(AppletsConfig appletsConfig)
    {
        return appletsConfigMapper.updateAppletsConfig(appletsConfig);
    }

    /**
     * 批量删除applets配置
     * 
     * @param ids 需要删除的applets配置ID
     * @return 结果
     */
    @Override
    public int deleteAppletsConfigByIds(Long[] ids)
    {
        return appletsConfigMapper.deleteAppletsConfigByIds(ids);
    }

    /**
     * 删除applets配置信息
     * 
     * @param id applets配置ID
     * @return 结果
     */
    @Override
    public int deleteAppletsConfigById(Long id)
    {
        return appletsConfigMapper.deleteAppletsConfigById(id);
    }

    /**
     * 小程序初始化参数
     *
     * @param id applets配置ID
     * @return 结果
     */
    @Override
    public void AppletsConfigAppidInit(String appid,Long id){
        ywInitData.modAppidById(appid,id);
    }

    /**
     * 小程序初始化参数参数
     *
     * @param id applets配置ID
     * @return 结果
     */
    @Override
    public void AppletsConfigInit(Long id, AppletsConfig appletsConfig) {
        ywInitData.modIdByConfig(id,appletsConfig);
    }
}
